<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <div id="app">
        <router-view></router-view>
    </div>

    <script src="./vue.js"></script>
    <script src="./vue-router.js"></script>
    <script>
    
    const user = {
        template:`
        <div>个人中心</div>
        `
    }
    const index = {
        template:`
        <div>
        <header>头部导航<router-link to='/user'>个人中心</router-link></header>
        <router-view></router-view>
        <footer>底部导航</footer>
        </div>
        `

    }
    const article = {
        template:`
         <div>文章详情{{$route.params.id}}</div>
        `
    }
    const list = {
        template:`
        <div>列表{{$route.params.id}}</div>
        `
    }
    const routes = [{
        path:'/user',
        component:user
    },{

        path:'/',
        component:index,
        redirect:'/article/10',
        children:[{
            path:'/article/:id',
            component:article
        },{
            path:'/list/:id',
            component:list
        }
        ]
    }
    ]
    const router = new VueRouter({
        routes
    })
    const app = new Vue({
        el:'#app',
        router
    })
    </script>
</body>
</html>